import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/vue-admin-template/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}

// 获取列表
export function getUserList(params) {
  return request({
    url: '/user',
    method: 'get',
    params
  })
}

// 更新
export function update(params) {
  request.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
  debugger
  return request({
    url: '/user',
    method: 'put',
    headers: { 'Content-Type': 'application/json;charset=UTF-8' },
    params
  })
}

// 启用禁用
export function enable(params) {
  request.defaults.headers.post['Content-Type'] = 'application/json;charset=UTF-8'
  return request({
    url: '/user/enable',
    method: 'put',
    headers: { 'Content-Type': 'application/json;charset=UTF-8' },
    params
  })
}

// 获取详情
export function get(id) {
  return request({
    url: '/user/' + id,
    method: 'get'
  })
}

// 检查email
export function check(params) {
  return request({
    url: '/user/check',
    method: 'get',
    params
  })
}
